﻿using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for Validator
/// </summary>
public class Validator
{
    /// <summary>
    /// 在页面上显示自定义错误
    /// </summary>
    /// <param name="container">在Form内的容器</param>
    /// <param name="message">错误消息</param>
	public static void AddCustomError(Control container, string message)
    {
        CustomValidator validator = new CustomValidator();
        validator.IsValid = false;
        validator.ErrorMessage = message;
        validator.Display = ValidatorDisplay.None;
        container.Controls.Add(validator);
    }
}